home *** CD-ROM | disk | FTP | other *** search
- From: miff@asharak.apana.org.au (michael smith)
- Subject: Re: load average patches for MiNT 1.10 + patches
- Date: Thu, 10 Mar 94 09:52:34+1030
- In-Reply-To: <2d7f745a1e7e81@anuurn.do.open.de> from "Martin Koehling" at Thu, 10 Mar 1994 20:25:14 MEZ
- Message-Id: <Up-ECKKAIXO@asharak.apana.org.au>
- Mime-Version: 1.0
- X-Software: Atari UUCP UPoint light (22. Jan. '94)
-
- In <2d7f745a1e7e81@anuurn.do.open.de> you wrote :
-
- >>michael smith writes:
- >>> but I don't believe in that sort
- >>> of ceiling regardless of how it's implemented, and someone is _bound_ to harp
- >>> on it.)
- >>
- >> true. thats also why you should always do timeouts checks like this
- >>
- >> unsigned tick = timer counter (like _hz_200) + time to wait;
- >> for (...)
- >> if (timer counter - tick > 0) break;
- >>
- >>instead of
- >> ...
- >> if (timer counter > tick) break;
- >>
- >>(and any compiler that `optimizes' the difference away should be shot. :)
- >
- >I don't quite see the difference between these two checks - they _both_
- >will come into trouble if `counter + time to wait' exceeds the value range
- >of `unsigned'!
- >The only *real* solution I can see is expanding the timer to a `long
- >long'...
-
-
- No, there is an easier way... (I use it a lot because most microcontrollers
- don't have large registers 8)
-
- old_counter = counter++;
- if (counter < old_counter) /* wrap condition */
- last_match = MAX_SIGNED_LONG - last_match; /* result is -ve */
-
- if (counter > (last_match + increment)) /* next event */
- {
- ...
-
- Note that the old_counter, counter and last_match need to be signed values.
-
- >Martin
-
-
- --
- --
- mike smith : silicon grease monkey | If you think it can't be done, |
- miff@asharak.apana.org.au | it means you don't have enough |
- miff@apanix.apana.org.au | money in your budget. |
-
-